package cn.tianjindong.blog_portal.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.tianjindong.blog.mapper.BlogMessageBoardMapper;
import cn.tianjindong.blog.pojo.BlogMessageBoard;
import cn.tianjindong.blog_portal.service.MessageService;

@Service
public class MessageServiceImpl implements MessageService {

	@Autowired
	private BlogMessageBoardMapper messageMapper;
	
	@Override
	public boolean addMessage(BlogMessageBoard message) {
		message.setCreatetime(new Date());
		message.setTab(0);// 标记为未读（0：未读，1已读）
		message.setTagReply(0);// 标记为未处理（0未处理，1已处理，2无用留言）
		if (message.getEmail() == null || message.getEmail().equals("") || message.getContent() == null
				|| message.getContent().equals("") || message.getTitle() == null || message.getTitle().equals("")) {
			return false;
		}
		try {
			messageMapper.insertSelective(message);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

}
